extends MySprites

@onready var animation_player: AnimatedSprite2D = $Animation

func _init():
	# 在初始化时修改变量的默认值
	health = 100
	attack = 30
	defence = 20
	is_player = true
	current_position = 2
	physical_position = 2
	
func _ready() -> void:
	animation_player.play("Idle")

#蘑菇怪的大招:对敌方一号位造成300%伤害
func use_ultimate_ability(players: Array, enemies: Array) -> void:
	var self_player = players[current_position]
	var target_enemy: StaticBody2D = get_first_alive_my_sprite(enemies)
	var damage = max(1, self_player.attack - target_enemy.defence) * 1
	await play_ultimate_animation(animation_player)
	await one_sprites_hited(target_enemy, damage)
	play_idle_animation(animation_player)
	switch_turn(is_player)
		
#蘑菇怪的普通技能:对敌方一号位造成100%伤害
func use_basic_ability(players: Array, enemies: Array) -> void:
	var self_player = players[current_position]
	var target_enemy: StaticBody2D = get_first_alive_my_sprite(enemies)
	var damage = max(1, self_player.attack - target_enemy.defence) * 1
	await play_basic_animation(animation_player)
	await one_sprites_hited(target_enemy, damage)
	play_idle_animation(animation_player)
	switch_turn(is_player)
	
	
func my_sprite_killed() -> void:
	# 播放死亡动画
	animation_player.play("Death")
	await animation_player.animation_finished
	

